package cn.springcloud.fix.provider.controller;

import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import cn.springcloud.fix.common.cache.annotation.AutoIdempotent;
import cn.springcloud.fix.common.core.base.BaseResponse;
import cn.springcloud.fix.common.core.base.Result;
import cn.springcloud.fix.provider.service.TokenService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@AllArgsConstructor
@RequestMapping("/home")
public class HomeController {

    private TokenService tokenService;

    @RequestMapping("/test")
    public BaseResponse test() {
        return BaseResponse.SUCCESS();
    }

    @PostMapping("/get/token")
    public BaseResponse getToken() {
        String token = tokenService.createToken();
        BaseResponse response = new BaseResponse();
        response.setData(token);
        return response;
    }

    @AutoIdempotent
    @PostMapping("/test/Idempotence")
    public String testIdempotence() {
        return StrUtil.EMPTY;
    }
}
